﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.Configuration;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class RegisterControl : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void CreateUserWizard_CreatedUser(object sender, EventArgs e)
    {
        string user = CreateUserWizard.UserName; //get UserName
        Roles.AddUserToRole(user, "websiteUser"); //add new user to role websiteUser

        TextBox firstName = (TextBox)CreateUserWizardStep1.ContentTemplateContainer.FindControl("FirstName"); //find the FirstName control in the CreateUserWizard
        TextBox lastName = (TextBox)CreateUserWizardStep1.ContentTemplateContainer.FindControl("LastName"); //find the LastName control in the CreateUserWizard

        string SqlQuery = "INSERT INTO userTable VALUES('" + user + "', 'http://educenterstorage.blob.core.windows.net/profile-images/noprofileimage.png','" + firstName.Text + "','" + lastName.Text + "');"; //insert new user into database

        Session["query"] = SqlQuery;

        Response.Redirect("CardRegister.aspx?userName=" + user); //redirect to cardregister with the username as query
    }
}